package cn.doctorpda.meeting.ui.splash;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import cn.doctorpda.meeting.R;
import cn.doctorpda.meeting.bean.Msg;
import cn.doctorpda.meeting.localstore.ClientInfo;
import cn.doctorpda.meeting.presenter.SplashPresenter;
import cn.doctorpda.meeting.ui.BaseFragment;
import cn.doctorpda.meeting.view.callbackview.IBaseView;

/**
 * Created by huangjinlong on 2016/5/13.
 */
public class SplashFragment extends BaseFragment implements IBaseView<String> {

    private SplashPresenter presenter;

    public static SplashFragment newInstance() {
        SplashFragment fragment = new SplashFragment();
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_splash, container, false);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        presenter = new SplashPresenter(this);
        String clientId = ClientInfo.getClientId(getActivity());
        if (TextUtils.isEmpty(clientId)) {
            presenter.getClientId();
        }
    }

    @Override
    public void setResult(Msg msg, String data) {
        ClientInfo.setClientId(getActivity(), data);
    }

}
